<?php

/**
 * Campaign filter form base class.
 *
 * @package    ecrm
 * @subpackage filter
 * @author     Saul Santiago
 * @version    SVN: $Id: sfDoctrineFormFilterGeneratedTemplate.php 29570 2010-05-21 14:49:47Z Kris.Wallsmith $
 */
abstract class BaseCampaignFormFilter extends BaseFormFilterDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'name'                    => new sfWidgetFormFilterInput(),
      'site_url'                => new sfWidgetFormFilterInput(),
      'start_date'              => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate())),
      'end_date'                => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate())),
      'contant_information_id'  => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('ContantInformation'), 'add_empty' => true)),
      'personal_information_id' => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('PersonalInformation'), 'add_empty' => true)),
      'company_information_id'  => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('CompanyInformation'), 'add_empty' => true)),
      'message'                 => new sfWidgetFormFilterInput(),
      'database_source_id'      => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('DatabaseSource'), 'add_empty' => true)),
      'kind_of_campaign'        => new sfWidgetFormFilterInput(),
      'created_at'              => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate(), 'with_empty' => false)),
      'updated_at'              => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate(), 'with_empty' => false)),
    ));

    $this->setValidators(array(
      'name'                    => new sfValidatorPass(array('required' => false)),
      'site_url'                => new sfValidatorPass(array('required' => false)),
      'start_date'              => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 00:00:00')), 'to_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 23:59:59')))),
      'end_date'                => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 00:00:00')), 'to_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 23:59:59')))),
      'contant_information_id'  => new sfValidatorDoctrineChoice(array('required' => false, 'model' => $this->getRelatedModelName('ContantInformation'), 'column' => 'id')),
      'personal_information_id' => new sfValidatorDoctrineChoice(array('required' => false, 'model' => $this->getRelatedModelName('PersonalInformation'), 'column' => 'id')),
      'company_information_id'  => new sfValidatorDoctrineChoice(array('required' => false, 'model' => $this->getRelatedModelName('CompanyInformation'), 'column' => 'id')),
      'message'                 => new sfValidatorPass(array('required' => false)),
      'database_source_id'      => new sfValidatorDoctrineChoice(array('required' => false, 'model' => $this->getRelatedModelName('DatabaseSource'), 'column' => 'id')),
      'kind_of_campaign'        => new sfValidatorPass(array('required' => false)),
      'created_at'              => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 00:00:00')), 'to_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 23:59:59')))),
      'updated_at'              => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 00:00:00')), 'to_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 23:59:59')))),
    ));

    $this->widgetSchema->setNameFormat('campaign_filters[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'Campaign';
  }

  public function getFields()
  {
    return array(
      'id'                      => 'Number',
      'name'                    => 'Text',
      'site_url'                => 'Text',
      'start_date'              => 'Date',
      'end_date'                => 'Date',
      'contant_information_id'  => 'ForeignKey',
      'personal_information_id' => 'ForeignKey',
      'company_information_id'  => 'ForeignKey',
      'message'                 => 'Text',
      'database_source_id'      => 'ForeignKey',
      'kind_of_campaign'        => 'Text',
      'created_at'              => 'Date',
      'updated_at'              => 'Date',
    );
  }
}
